import 'package:flutter/material.dart';
import 'package:huajianshe_app/base/AppNavigator.dart';
import 'package:huajianshe_app/common/AppRouter.dart';
import 'package:huajianshe_app/common/load_image.dart';
import 'package:huajianshe_app/common/res.dart';
import 'package:huajianshe_app/widget/RoundedCornerWidget.dart';

import 'CircleDetailPage.dart';
import 'model/CircleModel.dart';

class CircleItem extends StatelessWidget {

  final CircleListData? data;

  const CircleItem(this.data, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return 
      ColoredBox(color: Colors.white, 
          child: Padding(padding: EdgeInsets.symmetric(vertical: 10), 
              child: InkWell(onTap: () { AppNavigator.push(context, RouteName.CIRCLE_DETAIL, arguments: {'circleDetailType': CircleDetailType.inner, 'circleId': data?.id});},
                  child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
                    LoadImage.circleAvatar(data?.cover ?? '', 20, holderImg: 'placeholder'), //LoadImage(data?.cover, holderImg: 'placeholder'),
                    W(8),
                    Expanded(child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [
                      Text(data?.title ?? '', style: TS(15, C.gray0D0E15),),
                      H(1),
                      Text(data?.labels?.map((e) => '#${e.name}').toList().join(' | ') ?? '', style: TS(12, C.gray666),),
                      H(3),
                      Row(mainAxisSize: MainAxisSize.min, children: [
                        RoundedCornerWidget(child: Text('圈内人数${data?.memberNum}', style: TS(12, C.gray666, height: 1.3)), height: 18, backgroundColor: C.grayF6,
                        borderWidth: 0, radius: 2, padding: EdgeInsets.symmetric(horizontal: 4),),
                        W(14),
                        RoundedCornerWidget(child: Text('浏览人数${data?.viewNum}', style: TS(12, C.gray666, height: 1.3)), height: 18, backgroundColor: C.grayF6,
                          borderWidth: 0, radius: 2, padding: EdgeInsets.symmetric(horizontal: 4),),
                      ],)
                    ]))
                  ])
              )
          )
      );
  }
  
  String getLabels() {
    // print('${data?.labels}');
    return this.data?.labels?.map((e) {
      return '#${e.name}';
    }).toList().join('|') ?? '';
  }
}